<?php
require_once("database.php");
class xl_concentration extends database
{
	function danh_sach($vi_tri, $so_luong)
	{
		$vi_tri = intval($vi_tri);
		$so_luong = intval($so_luong);
		$sql = "select * from concentration limit $vi_tri, $so_luong";
		$this->setQuery($sql);
		return $this->loadAllRow();
	}
	function so_luong()
	{
		$sql = "select count(*) from concentration";
		$this->setQuery($sql);
		return $this->loadResult();
	}
	function xem($ccid, $from_uid)
	{
		$from_uid = intval($from_uid);

		$sql = "select * from concentration where ccid = '$ccid', from_uid = '$from_uid'";
		$this->setQuery($sql);
		return $this->loadRow();
	}
	function xoa($ccid, $from_uid)
	{
		$from_uid = intval($from_uid);

		$sql = "delete from concentration where ccid = '$ccid', from_uid = '$from_uid'";
		$this->setQuery($sql);
		$this->query();
	}
	function them($ccname)
	{
		$ccname = addslashes($ccname);

		$sql = "INSERT INTO concentration(ccname) VALUES ('$ccname')";
		$this->setQuery($sql);
		return $this->query();
	}
	function cap_nhat($ccid, $ccname, $from_uid)
	{
		$from_uid = intval($from_uid);
		$ccname = addslashes($ccname);

		$sql ="UPDATE concentration SET ccname= '$ccname' WHERE ccid = '$ccid', from_uid = '$from_uid'";
		$this->setQuery($sql);
		return $this->query();
	}
	function tim_kiem ($tu_khoa)
	{
		$sql = "select * from concentration where	$ccname like %tu_khoa%"; 
		$this->setQuery($sql);
		return $this->loadAllRow();	
	}
 }
?>